Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial review: Document popover="hint" #37990

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

chrisdavidmills
Copy link
Contributor

@chrisdavidmills chrisdavidmills commented Feb 6, 2025

Description

Chrome 133 supports the popover attribute hint value, which creates popovers that do not light-dismiss auto popovers when shown. This is useful for situations where, for example, you have toolbar buttons that can be pressed to show UI popovers, but you also want to reveal tooltips when the buttons are hovered, without dismissing the UI popovers.

This PR adds the HTML popover attribute hint value to the popover HTML global attribute page and the HTMLElement.popover DOM API equivalent.

It also adds a section explaining how to use popover="hint" to the Popover API "Using..." guide.

As a bonus, I've also added info about the implicit anchor references that are created between popovers (makes CSS anchor positioning easier to use with popovers).

See https://chromestatus.com/feature/5073251081912320 for the data source.

There is no reason why this can't be tech-reviewed now, but we can't merge it until the dom-examples example is reviewed and merged. I am therefore keeping this as a draft for now.

Motivation

Additional details

Related issues and pull requests

Fixes mdn/mdn#598
Fixes #38233

@chrisdavidmills chrisdavidmills requested review from a team as code owners February 6, 2025 16:59
@chrisdavidmills chrisdavidmills requested review from estelle and wbamberg and removed request for a team February 6, 2025 16:59
@chrisdavidmills chrisdavidmills marked this pull request as draft February 6, 2025 17:00
@github-actions github-actions bot added Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs labels Feb 6, 2025
@chrisdavidmills chrisdavidmills changed the title Document popover=hint Technical review: Document popover="hint" Feb 6, 2025
@github-actions github-actions bot added the size/m [PR only] 51-500 LoC changed label Feb 6, 2025
Copy link
Contributor

github-actions bot commented Feb 6, 2025

Preview URLs (16 pages)
Flaws (82)

Note! 7 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/API/Popover_API/Using
Title: Using the Popover API
Flaw count: 8

  • broken_links:
    • /en-US/docs/Glossary/top_layer is ill cased
    • /en-US/docs/Glossary/top_layer is ill cased
    • /en-US/docs/Glossary/inset_properties is ill cased
    • /en-US/docs/Glossary/top_layer is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect
    • Macro produces link /en-US/docs/Glossary/inset_properties which is a redirect
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect

URL: /en-US/docs/Web/API/HTMLElement
Title: HTMLElement
Flaw count: 5

  • broken_links:
    • /en-US/docs/Glossary/top_layer is ill cased
    • /en-US/docs/Glossary/top_layer is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect
    • Can't resolve /en-US/docs/Web/API/HTMLElement/cancel_event

URL: /en-US/docs/Web/API/HTMLElement/showPopover
Title: HTMLElement: showPopover() method
Flaw count: 2

  • broken_links:
    • /en-US/docs/Glossary/top_layer is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect

URL: /en-US/docs/Web/HTML/Element/input
Title: <input>: The HTML Input element
Flaw count: 46

  • broken_links:
    • /en-US/docs/Glossary/user_agent is ill cased
    • /en-US/docs/Glossary/user_agent is ill cased
    • /en-US/docs/Glossary/user_agent is ill cased
    • /en-US/docs/Web/API/validityState/rangeOverflow is ill cased
    • /en-US/docs/Web/API/validityState/tooLong is ill cased
    • and 18 more flaws omitted
  • macros:
    • Macro produces link /en-US/docs/Glossary/user_agent which is a redirect
    • Macro produces link /en-US/docs/Glossary/user_agent which is a redirect
    • Macro produces link /en-US/docs/Glossary/user_agent which is a redirect
    • Macro produces link /en-US/docs/Web/API/validityState/rangeOverflow which is a redirect
    • Macro produces link /en-US/docs/Web/API/validityState/tooLong which is a redirect
    • and 18 more flaws omitted

URL: /en-US/docs/Web/HTML/Element/button
Title: <button>: The Button element
Flaw count: 4

  • broken_links:
    • /en-US/docs/Glossary/user_agent is ill cased
    • /en-US/docs/Glossary/accessible_name is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/user_agent which is a redirect
    • Macro produces link /en-US/docs/Glossary/accessible_name which is a redirect

URL: /en-US/docs/Web/HTML/Global_attributes/popover
Title: popover
Flaw count: 2

  • broken_links:
    • /en-US/docs/Glossary/top_layer is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/top_layer which is a redirect

URL: /en-US/docs/Web/CSS/anchor-name
Title: anchor-name
Flaw count: 7

  • broken_links:
    • /en-US/docs/Glossary/inset_properties is ill cased
    • /en-US/docs/Web/CSS/Value_definition_syntax#single_bar is a redirect
    • /en-US/docs/Web/CSS/Value_definition_syntax#hash_mark is a redirect
  • macros:
    • Macro produces link /en-US/docs/Glossary/inset_properties which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/initial_value which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/inheritance which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/computed_value which is a redirect

URL: /en-US/docs/Web/CSS/CSS_anchor_positioning/Using
Title: Using CSS anchor positioning
Flaw count: 2

  • broken_links:
    • /en-US/docs/Glossary/inset_properties is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/inset_properties which is a redirect

URL: /en-US/docs/Web/CSS/position-anchor
Title: position-anchor
Flaw count: 6

  • broken_links:
    • /en-US/docs/Glossary/inset_properties is ill cased
    • /en-US/docs/Web/CSS/Value_definition_syntax#single_bar is a redirect
  • macros:
    • Macro produces link /en-US/docs/Glossary/inset_properties which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/initial_value which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/inheritance which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/computed_value which is a redirect
External URLs (3)

URL: /en-US/docs/Web/API/Popover_API/Using
Title: Using the Popover API


URL: /en-US/docs/Web/API/HTMLElement/anchorElement
Title: HTMLElement: anchorElement property


URL: /en-US/docs/Web/HTML/Global_attributes/anchor
Title: anchor

(comment last updated: 2025-02-21 08:49:33)

Copy link

@mfreed7 mfreed7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a few small comments.

@github-actions github-actions bot added the Content:CSS Cascading Style Sheets docs label Feb 12, 2025
@chrisdavidmills chrisdavidmills marked this pull request as ready for review February 12, 2025 15:07
@chrisdavidmills chrisdavidmills requested a review from a team as a code owner February 12, 2025 15:07
@chrisdavidmills chrisdavidmills changed the title Technical review: Document popover="hint" Editorial review: Document popover="hint" Feb 12, 2025
- `source` {{optional_inline}}
- : An {{domxref("HTMLElement")}} reference; programmatically defines the invoker of the popover associated with the toggle action, that is, the control button or link associated with the popover.

Associating a popover with a control using the `source` option creates an implicit anchor reference between the two. This makes it very convenient to position popovers relative to their controls using [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning). Explicit associations do not need to be made using the {{cssxref("anchor-name")}} and {{cssxref("position-anchor")}} properties.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Collaborator

@hamishwillee hamishwillee Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisdavidmills I'm closing all these, but once you've looked at https://github.com/mdn/content/pull/37990/files#r1958808280 you might want to link these to a fixed up section in the Using doc as an intermediate step to getting to the CSS anchor positioning doc.

I.e. "Associating anchor and positioned elements for more details on anchor references." is very general, whereas a specific example for popover hints would be very specific and make things a lot easier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, in my next commit, I have updated all of these bits to briefly explain all of the useful additional effects, and link to the relevant sections in the "Using..." guides. I don't want to repeat the entire explanation on each page.

chrisdavidmills and others added 3 commits February 14, 2025 12:32
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@yisibl
Copy link

yisibl commented Feb 17, 2025

We should probably add some indication that Interest Invokers can be used in the future to make it trigger via hover.

https://open-ui.org/components/interest-invokers.explainer

@mfreed7
Copy link

mfreed7 commented Feb 18, 2025

We should probably add some indication that Interest Invokers can be used in the future to make it trigger via hover.

https://open-ui.org/components/interest-invokers.explainer

I think MDN's policy is to only document things that are available in the platform, not future stuff. But I'm not positive about that.

@chrisdavidmills
Copy link
Contributor Author

We should probably add some indication that Interest Invokers can be used in the future to make it trigger via hover.
https://open-ui.org/components/interest-invokers.explainer

I think MDN's policy is to only document things that are available in the platform, not future stuff. But I'm not positive about that.

That's correct. I'm aware of the interest invokers stuff, but we should save it for a separate PR, when it is implemented.

@@ -29,9 +29,9 @@ Historically, associating an element with another element and dynamically changi

## Associating anchor and positioned elements

To associate an element with an anchor, you need to first declare which element is the anchor, and then specify which positioned element(s) to associate with that anchor. This can be done via CSS or via the HTML [`anchor`](/en-US/docs/Web/HTML/Global_attributes/anchor) attribute.
To associate an element with an anchor, you need to first declare which element is the anchor, and then specify which positioned element(s) to associate with that anchor. This creates an anchor reference between the two. This association can be created explicitly via CSS or via the HTML [`anchor`](/en-US/docs/Web/HTML/Global_attributes/anchor) attribute, or in some cases, implicitly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a follow-up: Do we still want to document the anchor attribute? It's not shipped in any browsers and afaik doesn't seem like it will soon because the wider whatwg/csswg aren't convinced by it. This is partly what lead to popovertarget (and commandfor pointing at a popover) creating an implicit anchor relationship.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ended up documenting the anchor attribute very early on because it was available in Canary and seemed to be a goer. If it looks like it will be killed off, I am happy to remove it. Maybe file an issue about it and wait for more definite action either way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha h! I just commented on this pointing to you @chrisdavidmills . Josh's summation there is correct - the reference is OK because it accurately reflects the situation, but the guide should remove the discussion around use of the anchor until this is either removed or released (not in canary).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b9c9e03

Copy link
Contributor

@lukewarlow lukewarlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-authoritative LGTM

@@ -341,11 +355,31 @@ See our [Popover blur background example](https://mdn.github.io/dom-examples/pop

### Implicit popover anchor associations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I still think I'm more likely to find this topic if you call it "Positioning a popover" or "Position a popover relative to its invoker". This heading only means something to me because I already understand it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to push back on this. I don't think changing the heading to something like this would make it particularly easier to find the section, and it would also be kind of inaccurate as to the focus of the section. It's not about positioning the popovers; that's covered in the previous section. This section is specifically about the fact that you don't need to include the anchor position association CSS features the elements in question are popovers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a compromise, I have promoted it to an h2, to make it more visible on the actual page.

@@ -341,11 +355,31 @@ See our [Popover blur background example](https://mdn.github.io/dom-examples/pop

### Implicit popover anchor associations

Associating a popover with a control using the [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) and [`id`](/en-US/docs/Web/HTML/Global_attributes/id) attributes creates an implicit anchor reference between the two, as does programmatically associating a popover action such as {{domxref("HTMLElement.showPopover", "showPopover()")}} with a control using the `source` option. See [Associating anchor and positioned elements](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using#associating_anchor_and_positioned_elements) for more details on anchor references.
Associating a popover with its invoker using the [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) attribute or the `source` option of the {{domxref("HTMLElement.showPopover()")}} or {{domxref("HTMLElement.togglePopover()")}} methods creates an implicit anchor reference between the two.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth spelling out that this works for both hints and autos.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS I very much like this update. I hope you agree it was worth the effort :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth spelling out that this works for both hints and autos.

It works for manual popovers too. I've clarified this by changing the first line to "Associating any kind of popover..."

PS I very much like this update. I hope you agree it was worth the effort :-)

Indeed, I do ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
6 participants